home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / EDITOR / FUGUE_3.ARJ / WF.017 < prev    next >
Text File  |  1990-11-05  |  18KB  |  487 lines

  1. .f3                              - # -              Chapter 17 - Mail Merge
  2. .rm70
  3. .mt5
  4. .mb5
  5. .pl66
  6. .tc
  7. .tc 17. MAIL MERGE ........................................#
  8. CHAPTER 17   MAIL MERGE
  9.  
  10. Mail Merge, or Merge Printing, is the process of inserting information
  11. into a document while it is being printed. The document is often
  12. printed several times with different information. The most common use
  13. of merge printing is to merge mailing list information into a form
  14. letter or mailing labels. Other applications include invoices,
  15. reports, and any other standard document that requires you to fill in
  16. blanks.
  17.  
  18. To merge print you need to create the form or template document (also
  19. called the master document). You usually need a data file as well. You
  20. then print the master document using the background print command Ctrl
  21. K P. Word fugue will obey the mail merge dot commands, and insert
  22. information in place of variables in your master document. If you are
  23. using a data file, a copy of the document will be produced for each
  24. set of information in the data file.
  25.  
  26. A master document contains the text of the document and the
  27. instructions for how the documents are to be produced. These
  28. instructions include variables and special merge print dot commands.
  29. An example would be a form letter and a data file of names and
  30. addresses.
  31.  
  32. .tc    Variables ..........................................#
  33. Variables
  34.  
  35. A variable is information that changes from one copy of the document
  36. to another. When you merge print, Word Fugue inserts information for
  37. each variable into each copy. This information can come from a data
  38. file, or you can be prompted for it when you print.
  39.  
  40. Each variable has a name, and you place the name of the variable into
  41. the master document wherever information is to be inserted. The actual
  42. information inserted in place of the variable is called data.
  43.  
  44. A variable name can contain up to 20 characters. You can use uppercase
  45. and lowercase letters interchangeably. You can make a name more
  46. readable by using hyphens (-) or underscores (_) to join words in the
  47. variable name.
  48.  
  49. Where you want to insert variable data, type the variable name between
  50. ampersands (&) in the text of the document:
  51.  
  52.    &person-name&                         Fred Nurk
  53.    &ADDress_1&                           The street
  54.    &city&, &state& &postcode&            Erehwon, XYZ 9000
  55.  
  56. If you have never set a value for a variable, it is termed
  57. uninitialised. These variables print their own name, to aid you in
  58. finding them. They usually happen when you misspell their name. word
  59. Fugue cannot match the misspelling, and so prints the name instead.
  60.  
  61. .tc    Merge Print Dot Commands ...........................#
  62. Merge Print Dot Commands
  63.  
  64. You type dot commands in the master document to tell Word Fugue the
  65. variable names and where to get the data that goes into them. If you
  66. do not obtain data for a variable name, Word Fugue will print the name
  67. instead. You cannot use a piece of data which is longer than 80
  68. characters. The total amount of data to be merged is limited by the
  69. memory available on your PC.
  70.  
  71. The following dot commands are available:
  72.  
  73.                 .DF filename delim
  74.                 .RV variable list
  75.                 .AV prompt,variable
  76.                 .SV variable=value
  77.                 .MA variable=equation
  78.                 .DM message
  79.                 .GO go to top of file and start again
  80.                 .WS Y or N for Wordstar compatible variable
  81.                     replacement
  82.  
  83. The .DF command defines the data file containing the variables to be
  84. merged into the text. If you follow the filename by at least one
  85. blank and another character, then that character is used as a
  86. delimiter instead of a comma
  87.  
  88.         eg .DF names.dat /
  89.  
  90. means that the file NAMES.DAT contains the variables to be read, and
  91. that the separator between variables is a slash (/). The default is
  92. comma (,).
  93.  
  94. The .RV command defines the variables to be found on a single line of
  95. the data file. You can have more that one .RV to define different
  96. lines of your master document. If a line of the data file is exhausted
  97. before all the variables are read, the remainder are set to blank.
  98.  
  99.         eg .RV name,address1,address2
  100.  
  101. means that each line of the file will look like this:
  102.  
  103.         Joe Bloggs,17 West street,Newtown DG 9999
  104.  
  105. If you want to leave a variable blank, then leave it out:
  106.  
  107.         Joe Bloggs,,Newtown Post Office DG 9999
  108.  
  109. You can use a different separator, as defined on the .DF line, and put
  110. different variables on different lines:
  111.  
  112.         .DF names.dat /
  113.         .rv name,address1
  114.         .rv address2
  115.  
  116. Your file would then look like this:
  117.  
  118.         Joe Bloggs/17 Westside Ave.,
  119.         Newtown DG 9999
  120.  
  121. .cp7
  122. The .AV line will prompt you to enter the contents of the variable.
  123. You can include an optional prompt:
  124.  
  125.         .AV Address1
  126.  
  127. will display   ADDRESS1?  and open a window for you to enter the
  128. value.
  129.  
  130.         .AV Enter the address,address1
  131.  
  132. will display  Enter the address  and open a window for you to enter
  133. the value.
  134.  
  135. The .SV line sets the variable to the value:
  136.  
  137.         .SV vara,this is the value for variable A
  138.         .SV addr= This is the address
  139.  
  140. You can use either comma (,) or equals sign (=). Leading spaces in the
  141. variable are ignored. If you want to include leading spaces, you
  142. should enclose the data within single or double quotes. If you start
  143. with a single quote, you must end with a single quote, and vice
  144. versa:
  145.  
  146.         .SV company= "   Fugue Software  "
  147.  
  148. You can set the maximum length of a variable by placing the characters
  149. /L and a length, or /R and a length, or /C and a length, depending on
  150. whether you want your data Left justified or Right justified or
  151. Centred, after the variable name:
  152.  
  153.         .SV A/L15=Joe Bloggs
  154.         .SV B/R15=Joe Bloggs
  155.         .SV C =Joe Bloggs
  156.         .SV D/C15=Joe Bloggs
  157.  
  158.         gives
  159.            A = "Joe Bloggs     "
  160.            B = "     Joe Bloggs"
  161.            C = "Joe Bloggs"
  162.            D = "   Joe Bloggs  "
  163.  
  164. If the line were too long, it would be truncated at the length
  165. specified.
  166.  
  167. The .MA line allows you to compute values and store them in another
  168. variable:
  169.  
  170.         .MA VARB=25*10
  171.         .MA varc= &vara&+&varb&
  172.         .MA total_price,&price&*(1-&discount&) * &qty&
  173.  
  174. The text within the '&' are other variables that will be replaced
  175. before the calculation is done. You can use any functions and
  176. operators that are provided by the pop up calculator, including
  177. booleans, since the same code is used for evaluation.
  178.  
  179. .cp5
  180. You can also have limited formatting when set in the .MA command.
  181. Follow the variable by $ for dollar format (2 decimal places) and by !
  182. for integer format. The default is as many decimal places as required:
  183.  
  184.        .MA  a = 1.2345
  185.           &a&           gives 1.2345
  186.  
  187.        .MA  a$ = 1.2345
  188.           &a&           gives 1.23
  189.  
  190.        .MA  a! = 1.2345
  191.           &a&           gives 1
  192.  
  193. The value is actually truncated to the number of places specified when
  194. assigned to the variable
  195.  
  196. The .DM line will display the following message. You can include
  197. variables which will be substituted before the message is displayed.
  198.  
  199.         .RV varb
  200.         .DM message is varb = &varb&
  201.  
  202. will display
  203.  
  204.        message is varb = the value of variable b
  205.  
  206. The .GO is used to exit from the current print and go back to the top
  207. of the file (assuming that there are more records to be printed)
  208.  
  209. .cp8
  210. The .WS is used to determine how variables in the text are replaced.
  211. You can set Y or N. The default is Y. All variables must be embedded
  212. within &s to be recognized and replaced. With the default, this is all
  213. that is needed:
  214.  
  215.                 &address1&
  216.                 &address2&
  217.  
  218. Setting .WS to N will mean that the variables within the text body
  219. must also be embedded inside print control brackets:
  220.  
  221.                 {.&address1&}
  222.                 {.&address2&}
  223.  
  224. .tc    Merge Printing Conditional Commands ................#
  225. Merge Printing Conditional Commands
  226.  
  227. Additional printing commands for evaluating conditional expressions
  228. and controlling the text that is printed.
  229.  
  230.                 .IF condition           is the IF condition
  231.                 .EL                     is the else
  232.                 .EI                     ends the IF expression.
  233.  
  234. You must have an .EI for every .IF, but you do not need to have .EL
  235. (else). The lines following the .IF are evaluated if the .IF were
  236. true, while the lines following the .EL are evaluated if the condition
  237. were false.
  238.  
  239. .tc      The IF Condition .................................#
  240. The IF Condition
  241.  
  242. Whether a condition is true is usually determined by comparing one
  243. item with another. If an item can be considered numeric (ie it
  244. consists only of digits), it is converted to a number before the
  245. comparison is done. Otherwise the comparison is done as text. The
  246. following comparisons are available:
  247.  
  248.         Operator        Meaning
  249.  
  250.         =               is the same as
  251.         <               is numerically less than or
  252.                         comes alphabetically before
  253.         >               is numerically greater than
  254.                         or comes alphabetically after
  255.         <=              is less than or equal to
  256.         >=              is greater than or equal to
  257.         <>              is not equal or not the same
  258.  
  259. The most common way to specify a condition to be evaluated is
  260.  
  261.         .IF item1 operator item2
  262.  
  263. .cp6
  264. For example, you can compare a merge print variable to a constant (a
  265. word, phrase or number that does not change) or to another merge print
  266. variable:
  267.  
  268.         .IF &pet& = dog
  269.         .IF &pet& = &pet_2&
  270.         .if &amt& = 12.35
  271.  
  272. In the first case, the condition is true if the value of the variable
  273. PET is dog. Note that uppercase and lower case are significant. In the
  274. second case, the condition is true if the value of the first variable
  275. is equal to the second variable. In the third case, the condition is
  276. true if the value of the variable is numerically equal to 12.35.
  277.  
  278. With strings of text, you should enclose them in quotes if leading or
  279. trailing spaces are significant. For 2 text items to be considered the
  280. same (=), they must consist of exactly the same characters.
  281.  
  282.         .IF "&pet&" = "    dog"
  283.         .if "&pet&" = "    dog's"
  284.  
  285. mean that the value of the variable PET must have 4 leading spaces.
  286.  
  287. Words are considered in alphabetic order, so that the following are
  288. true:
  289.  
  290.         .if cat < catalog
  291.         .IF catalog     >     cat
  292.  
  293. since cat comes before catalog in the dictionary.
  294.  
  295. In alphabetic order numbers come before letters. Note that the first
  296. variable determines the type of comparison. Text that cannot be
  297. converted to numbers for a numeric comparison is considered to be
  298. zero:
  299.  
  300.         .if 2<apple
  301.  
  302. is FALSE since 2 determines that the comparison will be numeric, and
  303. apple converts to the number 0. Whereas:
  304.  
  305.         .if apple>2
  306.  
  307. is TRUE, since apple is alphabetically after 2.
  308.  
  309. You can also use the .if command with just one variable name, in which
  310. case the condition is true if the variable is not zero or blank.
  311.  
  312.         .if &pet&
  313.  
  314. will be true if the variable PET contains a non zero non blank value.
  315.  
  316. Note 1. that a variable that has never been initialised will return a
  317.         blank in this situation.
  318.  
  319.      2. If your variable will contain text with spaces, enclose the
  320.         variable in quotes to perform the test:
  321.  
  322.        .if "&pet&"
  323.  
  324. .cp6
  325. .tc        Complex Conditions .............................#
  326. Complex Conditions
  327.  
  328. You can use mathematical equations on either side of the relational
  329. operator, and can join conditions together by using AND and OR. The
  330. following additional operators are available:
  331.  
  332.         AND             true and true => true
  333.                         anything else => false
  334.         OR              false and false => false
  335.                         anything else   => true
  336.  
  337.         XOR             true xor false  => true
  338.                         false xor true  => true
  339.                         true xor true   => false
  340.                         false xor false => false
  341.  
  342.         NOT             not true        => false
  343.                         not false       => true
  344.  
  345. .cp5
  346. You should use brackets to group parts of the condition for easier
  347. understanding:
  348.  
  349.     .IF (&PET& = dog) and (&pet2& = cat)
  350.     .IF ((&pet& = dog) or (&pet& = cat)) and (&income& > 25000)
  351.  
  352. .cp12
  353. .tc      The End If .......................................#
  354. The End If
  355.  
  356. The .IF dot command is followed by the commands and text to be done if
  357. the condition is true. You must signify to Word Fugue where the text
  358. finishes, so the program knows where to start again if the condition
  359. is false. You indicate this by using the dot command .EI (End If)
  360.  
  361. Almost anything can come between a .IF and its corresponding .EI. This
  362. can include text or other dot commands:
  363.  
  364.         .IF (&debt_age& > 30) and (&debt_age& < 60)
  365.         According to our records, you account is overdue. Maybe you
  366.         have overlooked our invoice. Could you please pay $&amt& as
  367.         soon as possible? If you have paid in the last few days,
  368.         please disregard this warning.
  369.         .EI
  370.         .if (&debt_age&>=60)
  371.         .fi nasty.doc
  372.         .ei
  373.  
  374. In this example, if a debt is between 30 and 60 days old, a warning is
  375. printed. If it is 60 days or more overdue, a stringer message is
  376. printed. If it is under 30 days, no message is printed.
  377.  
  378. .cp9
  379. .tc      The Else Condition ...............................#
  380. The Else Condition
  381.  
  382. The else condition says what action to take if the corresponding IF
  383. were false. The phrase ELSE is represented by the dot command .EL.
  384. The previous example could be redone as:
  385.  
  386.         .if (&debt_age&>=60)
  387.         .fi nasty.doc
  388.         .el
  389.         According to our records, you account is overdue. Maybe you
  390.         have overlooked our invoice. Could you please pay $&amt& as
  391.         soon as possible? If you have paid in the last few days,
  392.         please disregard this warning.
  393.         .EI
  394.  
  395. You should note a subtle difference here. In the first example, a debt
  396. could be under 30 days, and no message would be printed. In this
  397. example, all debts are assumed to be overdue, so a warning will always
  398. be printed if the debt is under 60 days old.
  399.  
  400. .tc      Nested Ifs .......................................#
  401. Nested Ifs
  402.  
  403. You can use conditional print commands and have Word Fugue choose
  404. among three or more alternatives by nesting the commands. For example,
  405. you may want to have different text for debts that are over 90 days,
  406. over 60 days, and over 30 days, as well as not printing a warning if
  407. they are less than 30 days. You could set up individual IFs as in the
  408. first example, and each IF must be phrased in such a way as to exclude
  409. all the other conditions. (This is why we tested > 30 days and < 60
  410. days). Alternatively, you could separate each condition by ELSEs, and
  411. simplify the conditions:
  412.  
  413.   If the debt is more than 90 days old, insert SOLICITR.DOC, otherwise
  414.   if the debt is more than 60 days old, insert NASTY.DOC, or else if
  415.   the debt is more than 30 days old print a warning, or if the debt is
  416.   less than 2 days old, offer a discount for prompt payment:
  417.  
  418. .CP16
  419.     ┌───.IF &debt_age& > 90
  420.     │   .fi solicitr.doc
  421.     │   .el
  422.     │┌──.if &debt_age& > 60
  423.     ││  .fi nasty.doc
  424.     ││  .el
  425.     ││┌─.if &debt_age& > 30
  426.     │││ .fi warning.doc
  427.     │││ .el
  428.     │││┌.if &debt_age& < 2
  429.     ││││.fi discount.doc
  430.     │││└.ei
  431.     ││└─.ei
  432.     │└──.ei
  433.     └───.ei
  434.  
  435. Every .IF must have a corresponding .EI command. There are 4 IFs so
  436. there must be 4 EIs. The lines shown link up the IFs with their
  437. corresponding EIs.
  438.  
  439. .tc      Command Files ....................................#
  440. Command Files
  441.  
  442. A command file is a file that contains only (or mainly) dot commands.
  443. Command files can be very useful for controlling merge printing or for
  444. chaining together the chapters of a large document by use of the .FI
  445. file include command:
  446.  
  447.   Example 1
  448.  
  449.        ┌─────────────────────────┐
  450.        │.FI letter.txt           │
  451.        │.pa                      │
  452.        │.fi proposal.doc         │
  453.        │.pa                      │
  454.        │.fi specs.doc            │
  455.        └─────────────────────────┘
  456.  
  457. .cp20
  458.   Example 2
  459.  
  460.        ┌─────────────────────────────────────────────────────┐
  461.        │.DF names.txt                                        │
  462.        │.RV first_name,last_name                             │
  463.        │.RV address_1                                        │
  464.        │.RV address_2                                        │
  465.        │.RV city,state,postcode                              │
  466.        │.if &postcode&<2000                                  │
  467.        │.fi special.doc                                      │
  468.        │.el                                                  │
  469.        │.if (&postcode&=2620) and (&city& = Queanbeyan)      │
  470.        │.sv state = NSW                                      │
  471.        │.ei                                                  │
  472.        │.fi normal1.doc                                      │
  473.        │.if (&postcode&>=2000) and (&postcode& <=2110)       │
  474.        │.fi offer.doc                                        │
  475.        │.ei                                                  │
  476.        │.ei                                                  │
  477.        └─────────────────────────────────────────────────────┘
  478.  
  479. .CP5
  480. This document reads a data file called NAMES.TXT, and prints a special
  481. letter if the postcode is less than 2000. Otherwise, it ensures that
  482. all Queanbeyan addresses with postcode 2620 have the state set to NSW
  483. and not ACT. (The postcode 2620 is allocated to parts of ACT and NSW
  484. as well). It then prints a normal letter to these people. If they live
  485. in areas around Sydney (postcode 2000 to 2110), it also prints a
  486. special offer.
  487.